Skip to content

feat(compression): adapt Huffman coding to current architecture#22

Merged
midudev merged 1 commit into
mainfrom
midudev-adaptar-pr-algoritmos
Jul 22, 2026
Merged

feat(compression): adapt Huffman coding to current architecture#22
midudev merged 1 commit into
mainfrom
midudev-adaptar-pr-algoritmos

Conversation

@midudev

@midudev midudev commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Integrates the Huffman Coding contribution from feat(compression): implement Huffman coding algorithm and visualization #16 while preserving JuanchiiBM as the commit author.
  • Ports the removed React visualizer to the current lazy-loaded plain-DOM concept renderer.
  • Registers Compression and Huffman across the catalog, SPA loaders, category routes, SSR content, and English/Spanish copy.
  • Adds lazy code implementations for JavaScript, Python, Java, C++, and Rust.
  • Intentionally drops the obsolete Vite override from the original PR.

Supersedes #16 with an implementation based on the current architecture.

Validation

  • pnpm build
  • Browser verification of all 22 steps, both themes, responsive overflow, and lazy language loading

- Add Huffman coding algorithm for lossless data compression, including detailed descriptions and steps for visualization.
- Introduce new `HuffmanState` type for managing the algorithm's state during visualization.
- Update translations to include new algorithm and its description in both English and Spanish.
- Modify `package.json` to override Vite version for compatibility.

This commit enhances the compression category with a foundational algorithm widely used in data compression.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	src/components/ConceptVisualizer.tsx
#	src/i18n/translations.ts
#	src/lib/algorithms/index.ts
Copilot AI review requested due to automatic review settings July 22, 2026 09:16
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
alg0-dev Ready Ready Preview, Comment Jul 22, 2026 9:16am

@midudev
midudev merged commit c064dc6 into main Jul 22, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Huffman Coding as a new Compression algorithm in the alg0.dev catalog, adapting the original contribution to the current lazy-loaded Algorithm module + plain-DOM “concept” visualizer architecture.

Changes:

  • Introduces a new Compression category and registers Huffman Coding across SSR algorithm lists, catalog ordering, routing/loaders, and i18n category labels.
  • Adds a new concept visualizer (huffman) plus a step generator that drives the visualization through frequency counting, tree building, and code assignment.
  • Adds lazy-loaded non-JS code implementations (Python/Java/C++/Rust) wired into the language pack loaders.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib/visualizers/concept/index.ts Registers the new huffman concept renderer via dynamic import.
src/lib/visualizers/concept/huffman.ts Implements the Huffman concept visualizer (tree + node table + summary).
src/lib/types.ts Adds HuffmanState and extends ConceptState to support the new visualizer state.
src/lib/categories.ts Adds Compression slug + intro copy (EN/ES).
src/lib/algorithms/loaders.ts Adds huffman-coding algorithm loader and compression implementation group loaders.
src/lib/algorithms/index.ts Adds huffmanCoding to the SSR algorithm list and adds Compression to categories.
src/lib/algorithms/catalog.ts Adds catalog entry for Huffman Coding and includes Compression in category ordering.
src/lib/algorithms/compression.ts Adds the Huffman Coding algorithm module + step generator used by the concept visualizer.
src/lib/algorithms/python/index.ts Wires Compression implementations into the Python pack.
src/lib/algorithms/python/compression.ts Adds annotated Huffman implementation in Python.
src/lib/algorithms/java/index.ts Wires Compression implementations into the Java pack.
src/lib/algorithms/java/compression.ts Adds annotated Huffman implementation in Java.
src/lib/algorithms/cpp/index.ts Wires Compression implementations into the C++ pack.
src/lib/algorithms/cpp/compression.ts Adds annotated Huffman implementation in C++.
src/lib/algorithms/rust/index.ts Wires Compression implementations into the Rust pack.
src/lib/algorithms/rust/compression.ts Adds annotated Huffman implementation in Rust.
src/i18n/translations.ts Adds translated category label for Compression (EN/ES).
src/content/algorithms/huffman-coding.ts Adds long-form Huffman Coding description content (EN/ES).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +78 to +82
nodeStates?: Record<number, HNodeState>
highlightChar?: string | null
freqTable?: { char: string; freq: number; active?: boolean }[]
codes?: { char: string; code: string; freq: number; active?: boolean }[]
activeCode?: string | null
Comment on lines +18 to +23
Time Complexity:
Best: O(n log n)
Average: O(n log n)
Worst: O(n log n)

Space Complexity: O(n)
Comment on lines +45 to +50
Complejidad Temporal:
Mejor: O(n log n)
Promedio: O(n log n)
Peor: O(n log n)

Complejidad Espacial: O(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants